package com.th.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/** 交易类型 0支出 1收入
 * @author 第五组
 * @Description TODO
 * @createTime 2023-06-24 16:42
 */
@AllArgsConstructor
@Getter
public enum TransactionType {
    EXPENDITURE(0,"支出"),
    INCOME(1,"收入");

    private Integer code;
    private String name;

    /***
     * 获取当前类型
     * @param code
     * @return
     */
    public static TransactionType of(Integer code){
        return Stream.of(values()).
                filter(bean -> bean.code.equals(code))
                .findAny()
                .orElse(null);
    }
}
